package com.qying.code;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * concurrentHashMap源码分析
 */

public class ConcurrentHashMapTest {

    public static void main(String[] args) {
        ConcurrentHashMap map = new ConcurrentHashMap();

        //Map<Long, String> objectObjectHashMap = new HashMap<>();

        for (int i = 0; i < 10000; i++) {
            int finalI = i;
            new Thread(new Runnable() {
                @Override
                public void run() {
                    for (int i1 = 0; i1 < 10000; i1++) {
                        map.put( System.currentTimeMillis(), "test" + finalI + i1);
                    }
                    System.out.println("===============");
                }
            }).start();
        }

       /* for (int i = 0; i < 10000; i++) {
            int finalI = i;
            new Thread(new Runnable() {
                @Override
                public void run() {
                    objectObjectHashMap.remove( finalI);
                }
            }).start();
        }*/

        System.out.println(map.size());
    }
}
